type == Meta.WindowType.UTILITY;
}
- GetRunningApplicationsAsync(params, invocation) {
+ async GetRunningApplicationsAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
invocation.return_value(new GLib.Variant('(a{sa{sv}})', [this._runningApplications]));
}
- GetWindowsAsync(params, invocation) {
+ async GetWindowsAsync(params, invocation) {
let focusWindow = global.display.get_focus_window();
let apps = this._appSystem.get_running();
let windowsList = {};
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
constructor(allowList) {
this._allowlistMap = new Map();
+ this._uninitializedNames = new Set(allowList);
+ this._initializedPromise = new Promise(resolve => {
+ this._resolveInitialized = resolve;
+ });
+
this._watchList = allowList.map(name => {
return Gio.DBus.watch_name(Gio.BusType.SESSION,
name,
Gio.BusNameWatcherFlags.NONE,
- (conn_, name_, owner) => this._allowlistMap.set(name, owner),
- () => this._allowlistMap.delete(name));
+ (conn_, name_, owner) => {
+ this._allowlistMap.set(name, owner);
+ this._checkAndResolveInitialized(name);
+ },
+ () => {
+ this._allowlistMap.delete(name);
+ this._checkAndResolveInitialized(name);
+ });
});
}
/**
+ * @param {string} name - bus name for which the watcher got initialized
+ */
+ _checkAndResolveInitialized(name) {
+ if (this._uninitializedNames.delete(name) &&
+ this._uninitializedNames.size === 0)
+ this._resolveInitialized();
+ }
+
+ /**
+ * @async
* @param {string} sender - the bus name that invoked the checked method
* @returns {bool}
*/
- _isSenderAllowed(sender) {
+ async _isSenderAllowed(sender) {
+ await this._initializedPromise;
return [...this._allowlistMap.values()].includes(sender);
}
* Check whether the bus name that invoked @invocation maps
* to an entry in the allow list.
*
+ * @async
* @throws
* @param {Gio.DBusMethodInvocation} invocation - the invocation
* @returns {void}
*/
- checkInvocation(invocation) {
+ async checkInvocation(invocation) {
if (global.context.unsafe_mode)
return;
- if (this._isSenderAllowed(invocation.get_sender()))
+ if (await this._isSenderAllowed(invocation.get_sender()))
return;
throw new GLib.Error(Gio.DBusError,
Gio.DBus.session.own_name('org.gnome.Shell.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
}
- _createScreenshot(invocation, needsDisk = true, restrictCallers = true) {
+ async _createScreenshot(invocation, needsDisk = true, restrictCallers = true) {
let lockedDown = false;
if (needsDisk)
lockedDown = this._lockdownSettings.get_boolean('disable-save-to-disk');
return null;
} else if (restrictCallers) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return null;
"Invalid params");
return;
}
- let screenshot = this._createScreenshot(invocation);
+ let screenshot = await this._createScreenshot(invocation);
if (!screenshot)
return;
async ScreenshotWindowAsync(params, invocation) {
let [includeFrame, includeCursor, flash, filename] = params;
- let screenshot = this._createScreenshot(invocation);
+ let screenshot = await this._createScreenshot(invocation);
if (!screenshot)
return;
async ScreenshotAsync(params, invocation) {
let [includeCursor, flash, filename] = params;
- let screenshot = this._createScreenshot(invocation);
+ let screenshot = await this._createScreenshot(invocation);
if (!screenshot)
return;
async SelectAreaAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
}
}
- FlashAreaAsync(params, invocation) {
+ async FlashAreaAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
}
async PickColorAsync(params, invocation) {
- const screenshot = this._createScreenshot(invocation, false, false);
+ const screenshot = await this._createScreenshot(invocation, false, false);
if (!screenshot)
return;
/**
* Focus the overview's search entry
*
+ * @async
* @param {...any} params - method parameters
* @param {Gio.DBusMethodInvocation} invocation - the invocation
* @returns {void}
*/
- FocusSearchAsync(params, invocation) {
+ async FocusSearchAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
/**
* Show OSD with the specified parameters
*
+ * @async
* @param {...any} params - method parameters
* @param {Gio.DBusMethodInvocation} invocation - the invocation
* @returns {void}
*/
- ShowOSDAsync([params], invocation) {
+ async ShowOSDAsync([params], invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
/**
* Focus specified app in the overview's app grid
*
+ * @async
* @param {string} id - an application ID
* @param {Gio.DBusMethodInvocation} invocation - the invocation
* @returns {void}
*/
- FocusAppAsync([id], invocation) {
+ async FocusAppAsync([id], invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
/**
* Show the overview's app grid
*
+ * @async
* @param {...any} params - method parameters
* @param {Gio.DBusMethodInvocation} invocation - the invocation
* @returns {void}
*/
- ShowApplicationsAsync(params, invocation) {
+ async ShowApplicationsAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
invocation.return_value(null);
}
- GrabAcceleratorAsync(params, invocation) {
+ async GrabAcceleratorAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
invocation.return_value(GLib.Variant.new('(u)', [bindingAction]));
}
- GrabAcceleratorsAsync(params, invocation) {
+ async GrabAcceleratorsAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
invocation.return_value(GLib.Variant.new('(au)', [bindingActions]));
}
- UngrabAcceleratorAsync(params, invocation) {
+ async UngrabAcceleratorAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
}
- UngrabAcceleratorsAsync(params, invocation) {
+ async UngrabAcceleratorsAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
this._grabbers.delete(name);
}
- ShowMonitorLabelsAsync(params, invocation) {
+ async ShowMonitorLabelsAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;
invocation.return_value(null);
}
- HideMonitorLabelsAsync(params, invocation) {
+ async HideMonitorLabelsAsync(params, invocation) {
try {
- this._senderChecker.checkInvocation(invocation);
+ await this._senderChecker.checkInvocation(invocation);
} catch (e) {
invocation.return_gerror(e);
return;